<template>
  <div class="flex direction-column height-100">
    <el-table
      class="table" v-loading="loading" :data="lists"
      height="100%"
      :header-cell-style="{
        backgroundColor: themeColor,
        color: 'white',
        textAlign: 'center'
      }"
      :cell-style="{
        textAlign: 'center'
      }"
    >
      <div slot="empty" class="empty-lists">
        <svg-icon name="search"></svg-icon>
        <span class="empty-text">暂无数据</span>
      </div>
      <el-table-column v-for="column in columns" :key="column.label" v-bind="column">
        <template v-if="column.children">
          <el-table-column v-for="item in column.children" :key="item.label" v-bind="item"></el-table-column>
        </template>
      </el-table-column>
    </el-table>
<!--    <el-pagination-->
<!--      class="pagination" layout="total,prev,pager,next"-->
<!--      hide-on-single-page background-->
<!--      :current-page.sync="pagination.pageNumber" :page-size="pagination.pageSize"-->
<!--      :total="pagination.total"-->
<!--    ></el-pagination>-->
  </div>
</template>

<script>
export default {
  name: 'energy-efficiency-analysis-coal',
  data () {
    return {
      loading: false,
      lists: [],
      pagination: {
        pageNumber: 1,
        pageSize: 12,
        total: 30
      },
      columns: [
        {
          label: '区域',
          prop: 'col1'
        },
        {
          label: '基准值2015年',
          prop: 'col2'
        },
        {
          label: '2021年',
          children: [
            {
              label: '基础值',
              prop: 'col3'
            },
            {
              label: '控制目标（万吨）',
              prop: 'col4'
            },
            {
              label: '达标率',
              prop: 'col5'
            },
            {
              label: '差值',
              prop: 'col6'
            }
          ]
        },
        {
          label: '2022年',
          children: [
            {
              label: '基础值',
              prop: 'col7'
            },
            {
              label: '控制目标（万吨）',
              prop: 'col8'
            },
            {
              label: '达标率',
              prop: 'col9'
            },
            {
              label: '差值',
              prop: 'col10'
            }
          ]
        },
        {
          label: '2023年',
          children: [
            {
              label: '基础值',
              prop: 'col11'
            },
            {
              label: '控制目标（万吨）',
              prop: 'col12'
            },
            {
              label: '达标率',
              prop: 'col13'
            },
            {
              label: '差值',
              prop: 'col14'
            }
          ]
        }
      ]
    }
  },
  computed: {
    themeColor () {
      return this.$store.state.user.theme
    }
  },
  mounted () {
    this.query()
  },
  methods: {
    query () {
      this.loading = true
      // TODO
      const rand = () => Math.round(Math.random() * 99 + 1)
      const districts = this.$store.getters['user/districts']
      return new Promise((resolve) => {
        setTimeout(() => {
          resolve()
          let id = 1
          this.lists = districts.map((v, i) => ({
            id: id++,
            col1: v.name,
            col2: rand(),
            col3: rand(),
            col4: rand(),
            col5: rand(),
            col6: rand(),
            col7: rand(),
            col8: rand(),
            col9: rand(),
            col10: rand(),
            col11: rand(),
            col12: rand(),
            col13: rand(),
            col14: rand(),
          }))
          this.loading = false
        }, 400)
      })
    },
  },
}
</script>

<style scoped>

</style>
